package com.itmuch.cloud.microserviceprovideruser.controller;

import com.itmuch.cloud.microserviceprovideruser.entity.User;
import com.itmuch.cloud.microserviceprovideruser.repository.UserRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
public class UserController {

    @Resource
    private UserRepository userRepository;

    @GetMapping(value = "/{id}",produces = { "application/json;charset=UTF-8" })
    public User findById(@PathVariable Long id)
    {
        User findOne = userRepository.findOne(id);
        if(findOne == null)
        {
            log.info("【用户为服务】没有此用户");
        }
        return findOne;
    }
}
